#include "m_hminsert.h"
#include "ui_m_hminsert.h"

#include <QMessageBox>
#include <QSqlQuery>

m_HMinsert::m_HMinsert(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::m_HMinsert)
{
    ui->setupUi(this);
}

m_HMinsert::~m_HMinsert()
{
    delete ui;
}

void m_HMinsert::on_confirmBtn_accepted()
{
    QSqlQuery query;
    QString sid=ui->sidEdit->text();
    QString sname=ui->snameEdit->text();
    QString ssex=ui->ssexEdit->text();
    QString sphone=ui->sphoneEdit->text();
    QString address=ui->haddressEdit->text();
    //QString sbuildid=ui->sbuildEdit->text();
    QString spwd=ui->spwdEdit->text();

    QString str=QString("insert into housemaster values('%1','%2','%3','%4','%5','%6')").
            arg(sid).arg(sname).arg(ssex).arg(sphone).arg(address).arg(spwd);
    qDebug()<<str;
    bool f1=query.exec(str);

//    str=QString("call a_housemaster('%1','%2','%3')").arg(build).arg(sid).arg(times);
//    qDebug()<<str;
//    bool f2=query.exec(str);

    if(f1){
        QMessageBox::information(NULL,"tips","添加成功");
        this->close();
    }
    else QMessageBox::warning(NULL,"Error","添加失败，请检查是否有内容写错");
}


void m_HMinsert::on_confirmBtn_rejected()
{
    this->close();
}

